package org.ziwei.paipan.biao;

import org.ziwei.paipan.var.DiZhi;

/**
 * 命身宫表
 * 夏历之前，正月是建子，二月建丑，可启用夏历之后，正月改建寅，二月建卯，依次类推
 * 从寅宫起正月，顺时针数到生月，由生月起子时，逆数到本人所生时辰安命宫
 * 例如五月辰时生人，从寅宫起正月，卯为二月，辰为三月，巳为四月，午为五月，生月在午，再由午起子时，逆时针数，巳为丑时，辰为寅时，卯为卯时，寅为辰时，因此命宫在寅宫
 * 由生月起子时，顺数到本人所生时辰安命宫
 * 例如五月辰时生人，从寅宫起正月，卯为二月，辰为三月，巳为四月，午为五月，生月在午，再由午起子时，顺时针数，未为丑时，申为寅时，酉为卯时，戌为辰时，因此身宫在戌宫
 */
public class MingShenGongBiao {

	/**
	 * 根据以上原理，计算出命宫表
	 * 横轴是出生时辰，纵轴是出生月份
	 */
	private static DiZhi[][] mingGongBiao = {
		{DiZhi.YIN,DiZhi.MAO,DiZhi.CHEN,DiZhi.SI,DiZhi.WU,DiZhi.WEI,DiZhi.SHEN,DiZhi.YOU,DiZhi.XU,DiZhi.HAI,DiZhi.ZI,DiZhi.CHOU},
		{DiZhi.CHOU,DiZhi.YIN,DiZhi.MAO,DiZhi.CHEN,DiZhi.SI,DiZhi.WU,DiZhi.WEI,DiZhi.SHEN,DiZhi.YOU,DiZhi.XU,DiZhi.HAI,DiZhi.ZI},
		{DiZhi.ZI,DiZhi.CHOU,DiZhi.YIN,DiZhi.MAO,DiZhi.CHEN,DiZhi.SI,DiZhi.WU,DiZhi.WEI,DiZhi.SHEN,DiZhi.YOU,DiZhi.XU,DiZhi.HAI},
		{DiZhi.HAI,DiZhi.ZI,DiZhi.CHOU,DiZhi.YIN,DiZhi.MAO,DiZhi.CHEN,DiZhi.SI,DiZhi.WU,DiZhi.WEI,DiZhi.SHEN,DiZhi.YOU,DiZhi.XU},
		{DiZhi.XU,DiZhi.HAI,DiZhi.ZI,DiZhi.CHOU,DiZhi.YIN,DiZhi.MAO,DiZhi.CHEN,Di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SI,DiZhi.WU,DiZhi.WEI,DiZhi.SHEN,DiZhi.YOU},
		{DiZhi.HAI,DiZhi.ZI,DiZhi.CHOU,DiZhi.YIN,DiZhi.MAO,DiZhi.CHEN,DiZhi.SI,DiZhi.WU,DiZhi.WEI,DiZhi.SHEN,DiZhi.YOU,DiZhi.XU},
		{DiZhi.ZI,DiZhi.CHOU,DiZhi.YIN,DiZhi.MAO,DiZhi.CHEN,DiZhi.SI,DiZhi.WU,DiZhi.WEI,DiZhi.SHEN,DiZhi.YOU,DiZhi.XU,DiZhi.HAI},
		{DiZhi.CHOU,DiZhi.YIN,DiZhi.MAO,DiZhi.CHEN,DiZhi.SI,DiZhi.WU,DiZhi.WEI,DiZhi.SHEN,DiZhi.YOU,DiZhi.XU,DiZhi.HAI,DiZhi.ZI}};
	
	
	/**
	 * 根据出生时辰和月份，返回命宫所在宫支
	 * @param month 出生月份
	 * @param shiChen 出生时辰
	 * @return DiZhi
	 */
	public static DiZhi anMingGong( int month, DiZhi shiChen){
		return mingGongBiao[shiChen.ordinal()][month];
	}
	
	
	/**
	 * 根据出生时辰和月份，返回身宫所在宫支
	 * @param month 出生月份
	 * @param shiChen 出生时辰
	 * @return DiZhi
	 */
	public static DiZhi anShenGong(int month, DiZhi shiChen){
		return shenGongBiao[shiChen.ordinal()][month];
	}	
}
